//声明: 该文件需要 jquery
$(function() {
	/*----top   下拉菜单----*/
	$(".float-right-mykd").hover(function() {
		$(".float-right-mykd ul").attr("class", "show")
	}, function() {
		$(".float-right-mykd ul").attr("class", "hide")
	})
	$(".float-right-help").hover(function() {
		$(".float-right-help ul").attr("class", "show")
	}, function() {
		$(".float-right-help ul").attr("class", "hide")
	})

	//商品分类

	$('.all-goods .item').hover(function() {

		$(this).addClass('active').find('s').hide();

		$(this).find('.product-wrap').show();

	}, function() {

		$(this).removeClass('active').find('s').show();

		$(this).find('.product-wrap').hide();

	});

	function setCookie(key, val, expires){
	var now = new Date();
	now.setDate( now.getDate()+expires );
	document.cookie = key+"="+val+"; expires="+now;
}

function getCookie(key){
	var cookiestr = document.cookie;
	var list = cookiestr.split("; ");
	for(var attr in list){
		var kv = list[attr].split("=");
		if(kv[0] == key){
			return kv[1];
		}
	}
	return "";
}
$("#queren").click(function() {
	/*	alert("注册成功");
				if($("#usernames").val() != '' && $("#password") != '' && $("#password").val() == $("#password").val()) {
		
					var user = $('input[name="username"]').val();
					var pwd = $('input[name="password"]').val()
					var pwd1 = $('input[id="password2"]').val()
		
					var users = getCookie("test") ? getCookie("test") : ""; //统一数据类型
					users = convertStrToObj(users);
					
					//获取cookie
					if(user in users) {
						alert("用户名已存在");
						return
					} else {
						users[user] = pwd; //将密码和用户名进行配对
						var users = convertObjToStr(users); //将对象转换成字符串，才能创建cookie
						setCookie("test", users, 7); //创建cookie
						console.log(decodeURIComponent(document.cookie));
						alert("注册成功");
		
					}
				}
			})*/
			
			
			var usernames = $("#usernames").val();
			var passwords = $("#password").val();
			if($("#usernames").val()!="" && $("#password").val()!=""){
				setCookie("name",usernames,10);
				setCookie("usernames",passwords,10);
				location.href="dldex.html";
				
			}else{
				alert("账号密码不能为空！")
			}
	})
})